package com.zsh.weather.ln.utils

import android.content.Context
import android.content.Context.INPUT_METHOD_SERVICE
import android.content.Intent
import android.view.inputmethod.InputMethodManager
import com.zsh.weather.ln.web.WebActivity


object Utils {
    fun openUrl(context: Context, location: String){
        var intent = Intent(context, WebActivity::class.java)
        //intent.setAction("android.intent.action.VIEW")
        intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
        //intent.setData(Uri.parse(url))
        intent.putExtra("location", location)
        context.startActivity(intent)
    }
    fun openUrl(context: Context, location: String,name: String){
        var intent = Intent(context, WebActivity::class.java)
        //intent.setAction("android.intent.action.VIEW")
        intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
        //intent.setData(Uri.parse(url))
        intent.putExtra("location", location)
        intent.putExtra("name",name)
        context.startActivity(intent)
    }
    fun inputKey(mContext: Context){
        val imm = (mContext
            .getSystemService(INPUT_METHOD_SERVICE) as InputMethodManager)!!
        imm!!.toggleSoftInput(0, InputMethodManager.HIDE_NOT_ALWAYS)
    }
}